package com.bianguo.android.functiondemo.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bianguo.android.functiondemo.R;
import com.bianguo.android.functiondemo.bean.AlbumData;
import com.bianguo.android.functiondemo.utils.GlideUtil;

import java.util.ArrayList;

import butterknife.BindView;

public class AlbumVideoAdapter extends BaseRecyclerAdapter<AlbumData> {

    public AlbumVideoAdapter(Context mContext, ArrayList<AlbumData> list) {
        super(mContext, list);
    }

    @Override
    public BaseViewHolder createHolder(@NonNull ViewGroup viewGroup, int viewType) {
        View view = inflater.inflate(R.layout.item_album_video_layout, viewGroup, false);
        return new ViewHolder(view);
    }

    @Override
    public void bindHolder(@NonNull BaseViewHolder baseViewHolder, int position) {
        ViewHolder viewHolder = (ViewHolder) baseViewHolder;
        AlbumData albumData = list.get(position);
        GlideUtil.loadImage(mContext, albumData.getPath(), viewHolder.albumVideoIv, -1);
        viewHolder.albumVideoIv.setOnClickListener(view -> {
            if (onClickItemListener != null) {
                onClickItemListener.onClickItemListener(this, view, viewHolder.getLayoutPosition());
            }
        });
    }

    public static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.item_album_video)
        ImageView albumVideoIv;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}
